from infirmary_admin_src.infirmary_common.infirmary_controller import IBaseController
from infirmary_admin_src.infirmary_common.infirmary_controller.rest_controller_with_depends import \
    RestControllerWithDepends
from fastapi import Request, Depends, Path, Body

from infirmary_admin_src.infirmary_smart_admin.infirmary_biz.infirmary.businesses.schemas import SchemaBase
from infirmary_admin_src.infirmary_smart_admin.infirmary_biz.infirmary.businesses.services.service_businesses import \
    Businesses


class XParam(SchemaBase):
    '''
    账号密码登录参数
    '''
    id: int = Body(0, title="departmentId", )
    appid: str = Body(..., title="departmentId", )
    name: str = Body(...,  title="departmentId", )
    pic: str = Body('',  title="managerId", )
    tel: str = Body(...,  title="name", )
    addr: str = Body('',  title="parent_id", )
    des : str = Body('',  title="parent_id", )
    tabs : str = Body('',  title="parent_id", )
    remakl  : str = Body('',  title="parent_id", )
    status : int = Body(0,  title="parent_id", )



class IController(IBaseController):
    '''
    定制相关约束检测函数逻辑步序
    '''

    def __init__(self, *, request: Request,
                 schema_param: XParam,
                 ):
        super().__init__(request=request)
        # 入参参数
        # 入参参数
        self.schema_param = schema_param


@RestControllerWithDepends()
class InfirmaryBusinessesUpdateController(IController):

    def business_login(self):
        pass
        result = Businesses.update_businesses_info(id=self.schema_param.id, **self.schema_param.dict(exclude={'id'}))
        if result:
            self.response_msg = '更新成功'
        else:
            self.response_ok = False
            self.response_msg = '更新失败'
            return None

        return None
